/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import Entity.Complaint;
import Entity.StaffViewComp;
import java.util.Vector;
import java.sql.*;

/**
 *
 * @author h10t93
 */
public class TechnicianProcess {

    DataConnection connection = new DataConnection();
    CallableStatement cs;
    ResultSet rs;

    public Vector<StaffViewComp> getComp(int id) {
        Vector<StaffViewComp> list = new Vector<StaffViewComp>();
        try {
            cs = connection.getConnection().prepareCall("procStaffviewComp ?");
            cs.setInt(1, id);

            rs = cs.executeQuery();
            while (rs.next()) {
                StaffViewComp svc = new StaffViewComp();
                svc.setWordID(rs.getInt(1));
                svc.setCompID(rs.getInt(2));
                svc.setCompTitle(rs.getString(3));
                svc.setContent(rs.getString(4));
                svc.setPriority(rs.getString(5));
                svc.setDate(rs.getString(6));
                list.add(svc);
            }
            rs.close();
            cs.close();
            connection.disconnection();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return list;
    }
     //staff resolve complaints
    public boolean resolveComp(int idWord, String solutin, int idComp) {
        int resul = 0;
        try {
            cs = connection.getConnection().prepareCall("procInserWordDetail ?,?,?");
            cs.setInt(1, idWord);
            cs.setString(2, solutin);
            cs.setInt(3, idComp);
            resul = cs.executeUpdate();
            cs.close();
            connection.disconnection();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return resul > 0;
    }
}
